#-----CLASS----------
class episode:
    def __init__(self, serie, season, episode, file_name):
        self.serie = re.sub('\.', ' ', serie[:-1])     #the last char is a .
        self.season = re.sub('[s,S]', '', season)
        self.episode = re.sub('[e,E]', '', episode)    #actually this isn't used...
        self.file_name = file_name
        
##Check path is ok, here is where i've to add the check for file
    def okToCopy(self, origin, destination, file):
        self.destination = os.path.abspath(self.destination)    #normalize path
        if not os.path.exists(self.destination):    #check if path exist
            try:
                os.makedirs(self.destination)
            except OSError as error:
                print 'There is an error: ', error
                return 0
            else:
                if os.path.exists(self.destination):
                    return 1
                else:
                    return 0
        else:
        #here if path exist, i've to check if the file exist too
            if not os.path.samestat(self.destination+file, self.origin+file):
                return 0
            else:    
                return 1    

##Copy the file
    def doCopy(self, ori_path, dest_path):
        if self.okToCopy(ori_path, dest_path, file):
            shutil.move(ori_path+self.file_name, dest_path)    
            print "Copied file: ", self.file_name
            
            
#-----GETTERS----------
    def getSeason(self):
        return self.season
    
    def getSerie(self):
        return self.serie

    def getEpisode(self):
        return self.episode
        
#--------------------
